// LSL script generated: RLV-New.RLV_MENU.DV_RLV_HUD rest.lslp Sun May  2 00:09:51 Westeuropäische Sommerzeit 2010
/*
################################################################################################################################# Included
0 6    B  Allow/prevent using inventory : @showinv=<y/n> 
1 6    B  Allow/prevent reading notecards : @viewnote=<y/n> 
2 6    B  Allow/prevent opening scripts : @viewscript=<y/n>     
3 6    B  Allow/prevent opening textures : @viewtexture=<y/n>
4 8    B  Allow/prevent touching objects located further than 1.5 meters away from the avatar : @fartouch=<y/n>     
5 8    B  Allow/prevent viewing the world map : @showworldmap=<y/n>     
6 8    B  Allow/prevent viewing the mini map : @showminimap=<y/n>     
7 8    B  Allow/prevent knowing the current location : @showloc=<y/n>
#################################################################################################################################
*/
integer attachment = 1;
string cmdname;
key victim;
list gMenu = [];
list statesMenu = [0,0,0,0,0,0,0,0];
key ToucherID;
integer channel_dialog;
integer listen_id;
string msg = "HUD Restrictions";
list sideMenu = [" ","Back"," "];

llRlvSay(string command){
    if ((attachment == 1)) {
        llOwnerSay(("@" + command));
    }
    else  {
        llSay(-1812221819,(((((cmdname + ",") + ((string)victim)) + ",") + "@") + command));
    }
}

MakeRLVState(){
    if ((attachment == 1)) {
        if ((llList2Integer(statesMenu,0) == 1)) llRlvSay("showinv=n");
        if ((llList2Integer(statesMenu,1) == 1)) llRlvSay("viewnote=n");
        if ((llList2Integer(statesMenu,2) == 1)) llRlvSay("viewscript=n");
        if ((llList2Integer(statesMenu,3) == 1)) llRlvSay("viewtexture=n");
        if ((llList2Integer(statesMenu,4) == 1)) llRlvSay("fartouch=n");
        if ((llList2Integer(statesMenu,5) == 1)) llRlvSay("showworldmap=n");
        if ((llList2Integer(statesMenu,6) == 1)) llRlvSay("showminimap=n");
        if ((llList2Integer(statesMenu,7) == 1)) llRlvSay("showloc=n");
    }
}

llLRP(integer element_new,integer placeinlist){
    (statesMenu = llListReplaceList(statesMenu,[element_new],placeinlist,placeinlist));
}

makeMenu(){
    (gMenu = []);
    (gMenu += sideMenu);
    if ((llList2Integer(statesMenu,0) == 1)) (gMenu += "[x]Inventory");
    else  (gMenu += "[ ]Inventory");
    if ((llList2Integer(statesMenu,1) == 1)) (gMenu += "[x]Notecards");
    else  (gMenu += "[ ]Notecards");
    if ((llList2Integer(statesMenu,2) == 1)) (gMenu += "[x]Scripts");
    else  (gMenu += "[ ]Scripts");
    if ((llList2Integer(statesMenu,3) == 1)) (gMenu += "[x]Textures");
    else  (gMenu += "[ ]Textures");
    if ((llList2Integer(statesMenu,4) == 1)) (gMenu += "[x]Far Touch");
    else  (gMenu += "[ ]Far Touch");
    if ((llList2Integer(statesMenu,5) == 1)) (gMenu += "[x]World Map");
    else  (gMenu += "[ ]World Map");
    if ((llList2Integer(statesMenu,6) == 1)) (gMenu += "[x]Mini Map");
    else  (gMenu += "[ ]Mini Map");
    if ((llList2Integer(statesMenu,7) == 1)) (gMenu += "[x]Location");
    else  (gMenu += "[ ]Location");
    (channel_dialog = (-1 * ((integer)("0x" + llGetSubString(((string)llGetKey()),-5,-1)))));
    (listen_id = llListen(channel_dialog,"",NULL_KEY,""));
    llDialog(ToucherID,msg,gMenu,channel_dialog);
    llSetTimerEvent(45.0);
}

default {

    state_entry() {
    }

    
    listen(integer channel,string name,key id,string message) {
        llListenRemove(listen_id);
        llSetTimerEvent(0.0);
        if ((message == "[x]Inventory")) {
            llLRP(0,0);
            llRlvSay("showinv=y");
            makeMenu();
        }
        if ((message == "[ ]Inventory")) {
            llLRP(1,0);
            llRlvSay("showinv=n");
            makeMenu();
        }
        if ((message == "[x]Notecards")) {
            llLRP(0,1);
            llRlvSay("viewnote=y");
            makeMenu();
        }
        if ((message == "[ ]Notecards")) {
            llLRP(1,1);
            llRlvSay("viewnote=n");
            makeMenu();
        }
        if ((message == "[x]Scripts")) {
            llLRP(0,2);
            llRlvSay("viewscript=y");
            makeMenu();
        }
        if ((message == "[ ]Scripts")) {
            llLRP(1,2);
            llRlvSay("viewscript=n");
            makeMenu();
        }
        if ((message == "[x]Textures")) {
            llLRP(0,3);
            llRlvSay("viewtexture=y");
            makeMenu();
        }
        if ((message == "[ ]Textures")) {
            llLRP(1,3);
            llRlvSay("viewtexture=n");
            makeMenu();
        }
        if ((message == "[x]Far Touch")) {
            llLRP(0,4);
            llRlvSay("fartouch=y");
            makeMenu();
        }
        if ((message == "[ ]Far Touch")) {
            llLRP(1,4);
            llRlvSay("fartouch=n");
            makeMenu();
        }
        if ((message == "[x]World Map")) {
            llLRP(0,5);
            llRlvSay("showworldmap=y");
            makeMenu();
        }
        if ((message == "[ ]World Map")) {
            llLRP(1,5);
            llRlvSay("showworldmap=n");
            makeMenu();
        }
        if ((message == "[x]Mini Map")) {
            llLRP(0,6);
            llRlvSay("showminimap=y");
            makeMenu();
        }
        if ((message == "[ ]Mini Map")) {
            llLRP(1,6);
            llRlvSay("showminimap=n");
            makeMenu();
        }
        if ((message == "[x]Location")) {
            llLRP(0,7);
            llRlvSay("showloc=y");
            makeMenu();
        }
        if ((message == "[ ]Location")) {
            llLRP(1,7);
            llRlvSay("showloc=n");
            makeMenu();
        }
        if ((message == "Back")) llMessageLinked(-4,1337,"DV_MAIN_RLV",ToucherID);
    }

    
    on_rez(integer on) {
    }

    
    link_message(integer sender,integer num,string str,key id) {
        if ((num == 1337)) {
            if ((str == llGetScriptName())) {
                llMessageLinked(-4,1338,llGetScriptName(),NULL_KEY);
                (ToucherID = id);
                makeMenu();
            }
        }
        if ((num == 1338)) {
            if ((str == "attachment")) (attachment = 1);
            else  if ((str == "device")) (attachment = 0);
            else  if ((str != llGetScriptName())) {
                llListenRemove(listen_id);
            }
        }
        if ((num == 1339)) {
            if ((str == "ON_REZ")) {
                MakeRLVState();
            }
            if ((str == "RESET")) {
                (statesMenu = [0,0,0,0,0,0,0,0]);
            }
        }
        if ((num == 1329)) {
            (victim = ((key)str));
            (cmdname = ((string)llGetKey()));
        }
    }

  	
  	timer() {
        llSetTimerEvent(0.0);
        llListenRemove(listen_id);
    }
}
